import btTable from "components/bt_table";
import {tableData} from './data'
import {actionEvents} from './action'

// 生成表单实例
const tableInstance = btTable({
  $$id: 'btTablex',
  options: {
    toolbar: '#toolbar',//工具栏
    columns: [
      {
          checkbox: true,
          field: 'state',
          align: 'center',
          width: 50,
          valign: 'middle'
      },
      {
          field: 'id',
          title: 'id',
          visible: false,
          valign: 'middle'
      },
      {
          field: 'name',
          title: '标题',
          valign: 'middle',
          sortable: true,
          editable: true
      },
      {
          field: 'price',
          title: '价钱',
          valign: 'middle'
      },
      {
          field: 'Desc',
          title: '操作',
          align: 'right',
          valign: 'middle',
          width: 140,
          events: actionEvents,
          formatter: function(value, row, index) {
            return [
              '<a class="ss-link-primary ss-block edit" href="javascript:void(0)" title="Edit">修改</a>',
              '<a class="ss-link-primary ss-block remove ml-small" href="javascript:void(0)" title="Remove">删除</a>'
            ].join('');
          },
      }
    ],
    data: tableData,
    loadingTemplate: function () {
      return '<i class="icon-loading"></i>'
    }
  }
})

function mkTable(){
  return tableInstance
}


export default mkTable
module.exports = mkTable
